<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['params']=array();
$sid=$this->checklogin();
//$return['buytype']=$this->buytypes();
$return['status']=array('0'=>'待付款','1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭','5'=>'申请维权','6'=>'已维权');
$return['status2']=array(
	array('id'=>1,'title'=>'待发货'),
	array('id'=>2,'title'=>'待收货'),
	array('id'=>3,'title'=>'已完成'),
	array('id'=>4,'title'=>'已关闭'),
	array('id'=>5,'title'=>'申请维权'),
	array('id'=>6,'title'=>'已维权'),
);
$return['paytype']=array('wechat'=>'微信支付','credit'=>'余额支付','3'=>'货到付款');
$return['ispay']=array('0'=>'未支付','1'=>'已支付');

if($_RQ['op']=='list'){	
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid);
    $orderby='createtime desc';
	$total='';
	
	if(!empty($_RQ['ordersn'])){
		$params['ordersn']=trim($_RQ['ordersn']);
		$return['params']['ordersn']=$_RQ['ordersn'];
	}
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if($_RQ['postdata']){
		$postdata=get_postdata();
		
	}
	if(trim($postdata['keyword'])){
		$params['ordersn']=trim($_RQ['ordersn']);
		$return['params']['ordersn']=trim($postdata['keyword']);
		
	}
	
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		if(!$v['nickname']){
			$v['nickname']='匿名用户';
		}
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'export'=>'export',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),			
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			array('op'=>'fa','title'=>'确认发货','type'=>'modal','show'=>array('status'=>1)),
			array('type'=>'href','op'=>'shou','title'=>'确认收货','show'=>array('status'=>2)),
			
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			array('name'=>'status','width'=>15,'title'=>'订单状态','type'=>'select','options'=>'status2'),
		)
	);
	if($_SESSION['os']=='mobile'){
		$return['htmls']=$this->template_url('manage/order_index');
	}else{
		$return['htmls']=$htmls;
	}
	
	exi($return);
	}
if($_RQ['op']=='export'){
	if(!empty($_RQ['ordersn'])){
		$params['ordersn']=trim($_RQ['ordersn']);
	}
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
	}
	$params['uniacid']=$_SESSION['uniacid'];
	$order=pdo_getall('jy_supplier_order',$params);
	$status=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$paytype=array('1'=>'微信支付','2'=>'余额支付');
	$ispay=array('0'=>'未支付','1'=>'已支付');
	foreach($order as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');		
		$address=pdo_get('core_address',array('id'=>$v['addressid'],'uniacid'=>$_SESSION['uniacid']));
		$v['address']=$address['province'].$address['city'].$address['address'];
		$v['mobile']=$address['mobile'];
		$v['realname']=$address['realname'];
		$q=$v['status'];
		$v['status']=$status[$q];
		$w=$v['paytype'];
		$v['paytype']=$paytype[$w];
		$e=$v['ispay'];
		$v['ispay']=$ispay[$e];
		if(!$v['nickname']){
			$v['nickname']='匿名用户';
		}
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$header=array(
	'ordersn'=>'订单号',
	'nickname'=>'买家昵称',
	'price'=>'金额',
	'status'=>'订单状态',
	'ispay'=>'金额',
	'paytype'=>'订单状态',
	'realname'=>'收货人姓名',
	'address'=>'收货地址',
	'mobile'=>'收货人电话',
	);
	cfc('tools')->export2excel($header,$order,'订单');
}
if($_RQ['op']=='fa'){
	$return['params']=array();
	$id=intval($_RQ['id']);
	$item['id']=$id;
	$htmls=array(
		'type'=>'edit',
		'post'=>'set',
		'desc'=>'订单发货',
		'edit'=>array(
			'0'=>array('type'=>'select','title'=>'快递公司','name'=>'express','options'=>'express','option_title'=>'name'),
			'1'=>array('type'=>'string','title'=>'快递单号','name'=>'expresssn'),
		)
	);
	$return['express']=Array ('0' => Array ( 'id'=> 1, 'name' => '顺丰快递' ), '1' => Array ( 'id' => 2, 'name' => '申通快递' ) ,'2' => Array ( 'id' => 3,'name' => '韵达快运' ), '3' => Array ('id' => 4, 'name' => '天天快递' ), '4' => Array ( 'id' => 5, 'name' => '圆通速递' ) ,'5' => Array ( 'id' => 6,'name' => '中通速递' ) ,'6' => Array ( 'id' => 7 ,'name' => 'ems快递' ), '7' => Array ( 'id' => 8, 'name' => '汇通快运' ), '8' => Array ( 'id' => 9, 'name' => '其它快递' )); 
	if($_SESSION['os']=='mobile'){
		$return['htmls']=$this->template_url('manage/order_index');
	}else{
		$return['htmls']=$htmls;
	}
	$return['op']='fa';
	$return['item']=$item;
	exi($return);
}
if($_RQ['op']=='set'){
	$post=get_postdata();
	$id=intval($post['id']);
	if(!$id){
		$id=intval($_RQ['id']);
	}
	if(!$id){
		exi('参数错误！','error');
	}
	
	if(!$post['express'] || !$post['expresssn']){
		exi('请填写快递信息','error');
	}
	$data=array('express_id'=>$post['express'],'expresssn'=>$post['expresssn']);
	$status=pdo_getcolumn('jy_supplier_order',array('id'=>$id),'status');
	if($status!=1){
		exi('订单不是未发货状态','error');
	}
	//pdo_insert('jy_supplier_order_express',$data,array('order_id'=>$id));
	pdo_update('jy_supplier_order',array('status'=>2,'express_id'=>$post['express'],'expresssn'=>$post['expresssn'],'sendtime'=>time()),array('id'=>$id));
	exi('已发货！','','/manage.order/');
}
if($_RQ['op']=='shou'){
	$id=intval($_RQ['id']);
	pdo_update('jy_supplier_order',array('status'=>3),array('id'=>$id));
	if($_SESSION['os']=='mobile'){
		exi('已收货','');
	}else{
		exi('已收货','','status3');
	}
	
}
if($_RQ['op']=='ispay'){
	$id=intval($_RQ['id']);
	pdo_update('jy_supplier_order',array('ispay'=>1,'status'=>1),array('id'=>$id));
	
	exi('已确认付款','');
	
	
}
if($_RQ['op']=='qx'){
	$id=intval($_RQ['id']);
	pdo_update('jy_supplier_order',array('status'=>5),array('id'=>$id));
	
	exi('已申请','');
	
	
}
if($_RQ['op']=='status1'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'status'=>1);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),			
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			array('op'=>'fa','title'=>'确认发货','type'=>'modal','show'=>array('status'=>1)),
			array('type'=>'href','op'=>'shou','title'=>'确认收货','show'=>array('status'=>2)),
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	if($_SESSION['os']=='mobile'){
		$return['htmls']=$this->template_url('manage/order_index');
	}else{
		$return['htmls']=$htmls;
	}
	$return['op']='status1';
	exi($return);
	}
if($_RQ['op']=='status2'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'status'=>2);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),			
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			array('op'=>'fa','title'=>'确认发货','type'=>'modal','show'=>array('status'=>1)),
			array('type'=>'href','op'=>'shou','title'=>'确认收货','show'=>array('status'=>2)),
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	if($_SESSION['os']=='mobile'){
		$return['htmls']=$this->template_url('manage/order_index');
	}else{
		$return['htmls']=$htmls;
	}
	$return['op']='status2';
	exi($return);
	}
if($_RQ['op']=='status3'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'status'=>3);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),				
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			array('op'=>'fa','title'=>'确认发货','type'=>'modal','show'=>array('status'=>1)),
			array('type'=>'href','op'=>'shou','title'=>'确认收货','show'=>array('status'=>2)),
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	if($_SESSION['os']=='mobile'){
		$return['htmls']=$this->template_url('manage/order_index');
	}else{
		$return['htmls']=$htmls;
	}
	$return['op']='status3';
	exi($return);
	}
if($_RQ['op']=='status4'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'status'=>4);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),					
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			array('op'=>'fa','title'=>'确认发货','type'=>'modal','show'=>array('status'=>1)),
			array('type'=>'href','op'=>'shou','title'=>'确认收货','show'=>array('status'=>2)),
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	if($_SESSION['os']=='mobile'){
		$return['htmls']=$this->template_url('manage/order_index');
	}else{
		$return['htmls']=$htmls;
	}
	$return['op']='status4';
	exi($return);
	}
if($_RQ['op']=='status5'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'status'=>5);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),					
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			array('op'=>'fa','title'=>'确认发货','type'=>'modal','show'=>array('status'=>1)),
			array('type'=>'href','op'=>'shou','title'=>'确认收货','show'=>array('status'=>2)),
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	$return['htmls']=$htmls;	
	exi($return);
	}
if($_RQ['op']=='status6'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'status'=>6);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),					
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			array('op'=>'fa','title'=>'确认发货','type'=>'modal','show'=>array('status'=>1)),
			array('type'=>'href','op'=>'shou','title'=>'确认收货','show'=>array('status'=>2)),
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	$return['htmls']=$htmls;	
	exi($return);
	}
if($_RQ['op']=='status0'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'ispay'=>0);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			//array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),				
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	if($_SESSION['os']=='mobile'){
		$return['htmls']=$this->template_url('manage/order_index');
	}else{
		$return['htmls']=$htmls;
	}	
	$return['op']='status0';
	exi($return);
}
if($_RQ['op']=='deleted'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid,'deleted'=>1);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			//array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),				
		),
		'action'=>array(	
			array('type'=>'href','action'=>'manage.detail','title'=>'订单详情'),
			
		),),
		
		'search'=>array(
			array('name'=>'order','width'=>15,'title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','width'=>15,'title'=>'用户昵称','type'=>'string'),
			//array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	$return['htmls']=$htmls;	
	exi($return);
}
if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_update('jy_supplier_order',array('deleted'=>1),array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_update('jy_supplier_order',array('deleted'=>1),array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>